#RECODING
########################################################
#Preparing data for analysis

setwd("")

rm(list=ls())

#Read in data frame

dataset_complete_waves1_2<-readRDS("dataset_complete_waves_1_2.rds")
names(dataset_complete_waves1_2)

#Recode pre-treatment covariates wave 1


#Demographics (baseline)

#Age

dataset_complete_waves1_2$age<-2015-dataset_complete_waves1_2$Dem_Birthyear_1

#impute mean for missing age

mean(dataset_complete_waves1_2$age, na.rm=TRUE)

dataset_complete_waves1_2$age[is.na(dataset_complete_waves1_2$age)]<-round(mean(dataset_complete_waves1_2$age, na.rm=TRUE), digits=0)

#Age missing

dataset_complete_waves1_2$age_mis[!is.na(dataset_complete_waves1_2$Dem_Birthyear_1)]<-0
dataset_complete_waves1_2$age_mis[is.na(dataset_complete_waves1_2$Dem_Birthyear_1)]<-1

#Marital Status

dataset_complete_waves1_2$married[dataset_complete_waves1_2$Dem_Marital_Status=="Verheiratet"]<-1
dataset_complete_waves1_2$married[dataset_complete_waves1_2$Dem_Marital_Status=="Ledig"]<-0
dataset_complete_waves1_2$married[is.na(dataset_complete_waves1_2$Dem_Marital_Status)]<-0
dataset_complete_waves1_2$married[dataset_complete_waves1_2$Dem_Marital_Status==""]<-0
dataset_complete_waves1_2$married[dataset_complete_waves1_2$Dem_Marital_Status=="Keine Angabe"]<-0
dataset_complete_waves1_2$married[dataset_complete_waves1_2$Dem_Marital_Status=="Eingetragene Partnerschaft"]<-1

dataset_complete_waves1_2$married_mis[dataset_complete_waves1_2$Dem_Marital_Status=="Verheiratet"]<-0
dataset_complete_waves1_2$married_mis[dataset_complete_waves1_2$Dem_Marital_Status=="Ledig"]<-0
dataset_complete_waves1_2$married_mis[is.na(dataset_complete_waves1_2$Dem_Marital_Status)]<-1
dataset_complete_waves1_2$married_mis[dataset_complete_waves1_2$Dem_Marital_Status==""]<-1
dataset_complete_waves1_2$married_mis[dataset_complete_waves1_2$Dem_Marital_Status=="Keine Angabe"]<-0
dataset_complete_waves1_2$married_mis[dataset_complete_waves1_2$Dem_Marital_Status=="Eingetragene Partnerschaft"]<-0


#Citizenship

dataset_complete_waves1_2$Swiss_citizenship[dataset_complete_waves1_2$Dem_Right_to_vote=="Ja"]<-1
dataset_complete_waves1_2$Swiss_citizenship[dataset_complete_waves1_2$Dem_Right_to_vote=="Nein"]<-0
dataset_complete_waves1_2$Swiss_citizenship[is.na(dataset_complete_waves1_2$Dem_Right_to_vote)]<-0
dataset_complete_waves1_2$Swiss_citizenship[dataset_complete_waves1_2$Dem_Right_to_vote==""]<-0


#Citizenship missing

dataset_complete_waves1_2$citizenship_mis<-0
dataset_complete_waves1_2$citizenship_mis[dataset_complete_waves1_2$Dem_Right_to_vote==""]<-1


#Start year University

dataset_complete_waves1_2$year_uni<-dataset_complete_waves1_2$Dem_University_Start_1

median(dataset_complete_waves1_2$year_uni, na.rm=TRUE)

#impute median

dataset_complete_waves1_2$year_uni[is.na(dataset_complete_waves1_2$year_uni)]<-(median(dataset_complete_waves1_2$year_uni, na.rm=TRUE))

#missing uni start
dataset_complete_waves1_2$year_uni_mis[!is.na(dataset_complete_waves1_2$Dem_University_Start_1)]<-0
dataset_complete_waves1_2$year_uni_mis[is.na(dataset_complete_waves1_2$Dem_University_Start_1)]<-1

table(dataset_complete_waves1_2$year_uni_mis)


#Employment father

dataset_complete_waves1_2$employment_father_1[dataset_complete_waves1_2$Dem_Employment_fathe=="Ja"]<-1
dataset_complete_waves1_2$employment_father_1[dataset_complete_waves1_2$Dem_Employment_fathe=="Nein"]<-0
dataset_complete_waves1_2$employment_father_1[is.na(dataset_complete_waves1_2$Dem_Employment_fathe)]<-0
dataset_complete_waves1_2$employment_father_1[dataset_complete_waves1_2$Dem_Employment_fathe==""]<-0

dataset_complete_waves1_2$employment_father_2[dataset_complete_waves1_2$Dem_Employment_fathe=="Ja"]<-0
dataset_complete_waves1_2$employment_father_2[dataset_complete_waves1_2$Dem_Employment_fathe=="Nein"]<-1
dataset_complete_waves1_2$employment_father_2[is.na(dataset_complete_waves1_2$Dem_Employment_fathe)]<-0
dataset_complete_waves1_2$employment_father_2[dataset_complete_waves1_2$Dem_Employment_fathe==""]<-0

dataset_complete_waves1_2$employment_father_3[dataset_complete_waves1_2$Dem_Employment_fathe=="Ja"]<-0
dataset_complete_waves1_2$employment_father_3[dataset_complete_waves1_2$Dem_Employment_fathe=="Nein"]<-0
dataset_complete_waves1_2$employment_father_3[is.na(dataset_complete_waves1_2$Dem_Employment_fathe)]<-1
dataset_complete_waves1_2$employment_father_3[dataset_complete_waves1_2$Dem_Employment_fathe==""]<-1


#Employment mother

dataset_complete_waves1_2$employment_mother_1[dataset_complete_waves1_2$Dem_Employment_mothe=="Ja"]<-1
dataset_complete_waves1_2$employment_mother_1[dataset_complete_waves1_2$Dem_Employment_mothe=="Nein"]<-0
dataset_complete_waves1_2$employment_mother_1[is.na(dataset_complete_waves1_2$employment_mother_1)]<-0

dataset_complete_waves1_2$employment_mother_2[dataset_complete_waves1_2$Dem_Employment_mothe=="Ja"]<-0
dataset_complete_waves1_2$employment_mother_2[dataset_complete_waves1_2$Dem_Employment_mothe=="Nein"]<-1
dataset_complete_waves1_2$employment_mother_2[is.na(dataset_complete_waves1_2$employment_mother_2)]<-0

dataset_complete_waves1_2$employment_mother_3[dataset_complete_waves1_2$Dem_Employment_mothe=="Ja"]<-0
dataset_complete_waves1_2$employment_mother_3[dataset_complete_waves1_2$Dem_Employment_mothe=="Nein"]<-0
dataset_complete_waves1_2$employment_mother_3[is.na(dataset_complete_waves1_2$employment_mother_3)]<-1


#Highest Qual Father

dataset_complete_waves1_2$edu_father_5[dataset_complete_waves1_2$Dem_Highest_qual_fat=="Hochschule"]<-1
dataset_complete_waves1_2$edu_father_5[dataset_complete_waves1_2$Dem_Highest_qual_fat=="Sekundarstufe II: Allgemeinbildung"]<-0
dataset_complete_waves1_2$edu_father_5[dataset_complete_waves1_2$Dem_Highest_qual_fat=="H_here Berufsbildung"]<-0
dataset_complete_waves1_2$edu_father_5[dataset_complete_waves1_2$Dem_Highest_qual_fat=="Sekundarstufe II: Berufsbildung"]<-0
dataset_complete_waves1_2$edu_father_5[dataset_complete_waves1_2$Dem_Highest_qual_fat=="Keine nach-obligatorische Ausbildung"]<-0
dataset_complete_waves1_2$edu_father_5[is.na(dataset_complete_waves1_2$edu_father_5)]<-0


dataset_complete_waves1_2$edu_father_4[dataset_complete_waves1_2$Dem_Highest_qual_fat=="Hochschule"]<-0
dataset_complete_waves1_2$edu_father_4[dataset_complete_waves1_2$Dem_Highest_qual_fat=="Sekundarstufe II: Allgemeinbildung"]<-1
dataset_complete_waves1_2$edu_father_4[dataset_complete_waves1_2$Dem_Highest_qual_fat=="H_here Berufsbildung"]<-0
dataset_complete_waves1_2$edu_father_4[dataset_complete_waves1_2$Dem_Highest_qual_fat=="Sekundarstufe II: Berufsbildung"]<-0
dataset_complete_waves1_2$edu_father_4[dataset_complete_waves1_2$Dem_Highest_qual_fat=="Keine nach-obligatorische Ausbildung"]<-0
dataset_complete_waves1_2$edu_father_4[is.na(dataset_complete_waves1_2$edu_father_4)]<-0


dataset_complete_waves1_2$edu_father_3[dataset_complete_waves1_2$Dem_Highest_qual_fat=="Hochschule"]<-0
dataset_complete_waves1_2$edu_father_3[dataset_complete_waves1_2$Dem_Highest_qual_fat=="Sekundarstufe II: Allgemeinbildung"]<-0
dataset_complete_waves1_2$edu_father_3[dataset_complete_waves1_2$Dem_Highest_qual_fat=="H_here Berufsbildung"]<-1
dataset_complete_waves1_2$edu_father_3[dataset_complete_waves1_2$Dem_Highest_qual_fat=="Sekundarstufe II: Berufsbildung"]<-0
dataset_complete_waves1_2$edu_father_3[dataset_complete_waves1_2$Dem_Highest_qual_fat=="Keine nach-obligatorische Ausbildung"]<-0
dataset_complete_waves1_2$edu_father_3[is.na(dataset_complete_waves1_2$edu_father_3)]<-0


dataset_complete_waves1_2$edu_father_2[dataset_complete_waves1_2$Dem_Highest_qual_fat=="Hochschule"]<-0
dataset_complete_waves1_2$edu_father_2[dataset_complete_waves1_2$Dem_Highest_qual_fat=="Sekundarstufe II: Allgemeinbildung"]<-0
dataset_complete_waves1_2$edu_father_2[dataset_complete_waves1_2$Dem_Highest_qual_fat=="H_here Berufsbildung"]<-0
dataset_complete_waves1_2$edu_father_2[dataset_complete_waves1_2$Dem_Highest_qual_fat=="Sekundarstufe II: Berufsbildung"]<-1
dataset_complete_waves1_2$edu_father_2[dataset_complete_waves1_2$Dem_Highest_qual_fat=="Keine nach-obligatorische Ausbildung"]<-0
dataset_complete_waves1_2$edu_father_2[is.na(dataset_complete_waves1_2$edu_father_2)]<-0


dataset_complete_waves1_2$edu_father_1[dataset_complete_waves1_2$Dem_Highest_qual_fat=="Hochschule"]<-0
dataset_complete_waves1_2$edu_father_1[dataset_complete_waves1_2$Dem_Highest_qual_fat=="Sekundarstufe II: Allgemeinbildung"]<-0
dataset_complete_waves1_2$edu_father_1[dataset_complete_waves1_2$Dem_Highest_qual_fat=="H_here Berufsbildung"]<-0
dataset_complete_waves1_2$edu_father_1[dataset_complete_waves1_2$Dem_Highest_qual_fat=="Sekundarstufe II: Berufsbildung"]<-0
dataset_complete_waves1_2$edu_father_1[dataset_complete_waves1_2$Dem_Highest_qual_fat=="Keine nach-obligatorische Ausbildung"]<-1
dataset_complete_waves1_2$edu_father_1[is.na(dataset_complete_waves1_2$edu_father_1)]<-0


dataset_complete_waves1_2$edu_father_mis[dataset_complete_waves1_2$Dem_Highest_qual_fat=="Hochschule"]<-0
dataset_complete_waves1_2$edu_father_mis[dataset_complete_waves1_2$Dem_Highest_qual_fat=="Sekundarstufe II: Allgemeinbildung"]<-0
dataset_complete_waves1_2$edu_father_mis[dataset_complete_waves1_2$Dem_Highest_qual_fat=="H_here Berufsbildung"]<-0
dataset_complete_waves1_2$edu_father_mis[dataset_complete_waves1_2$Dem_Highest_qual_fat=="Sekundarstufe II: Berufsbildung"]<-0
dataset_complete_waves1_2$edu_father_mis[dataset_complete_waves1_2$Dem_Highest_qual_fat=="Keine nach-obligatorische Ausbildung"]<-0
dataset_complete_waves1_2$edu_father_mis[is.na(dataset_complete_waves1_2$edu_father_mis)]<-1


#Highest Qual Mother

dataset_complete_waves1_2$edu_mother_5[dataset_complete_waves1_2$Dem_Highest_qual_mot=="Hochschule"]<-1
dataset_complete_waves1_2$edu_mother_5[dataset_complete_waves1_2$Dem_Highest_qual_mot=="Sekundarstufe II: Allgemeinbildung"]<-0
dataset_complete_waves1_2$edu_mother_5[dataset_complete_waves1_2$Dem_Highest_qual_mot=="H_here Berufsbildung"]<-0
dataset_complete_waves1_2$edu_mother_5[dataset_complete_waves1_2$Dem_Highest_qual_mot=="Sekundarstufe II: Berufsbildung"]<-0
dataset_complete_waves1_2$edu_mother_5[dataset_complete_waves1_2$Dem_Highest_qual_mot=="Keine nach-obligatorische Ausbildung"]<-0
dataset_complete_waves1_2$edu_mother_5[is.na(dataset_complete_waves1_2$edu_mother_5)]<-0

dataset_complete_waves1_2$edu_mother_4[dataset_complete_waves1_2$Dem_Highest_qual_mot=="Hochschule"]<-0
dataset_complete_waves1_2$edu_mother_4[dataset_complete_waves1_2$Dem_Highest_qual_mot=="Sekundarstufe II: Allgemeinbildung"]<-1
dataset_complete_waves1_2$edu_mother_4[dataset_complete_waves1_2$Dem_Highest_qual_mot=="H_here Berufsbildung"]<-0
dataset_complete_waves1_2$edu_mother_4[dataset_complete_waves1_2$Dem_Highest_qual_mot=="Sekundarstufe II: Berufsbildung"]<-0
dataset_complete_waves1_2$edu_mother_4[dataset_complete_waves1_2$Dem_Highest_qual_mot=="Keine nach-obligatorische Ausbildung"]<-0
dataset_complete_waves1_2$edu_mother_4[is.na(dataset_complete_waves1_2$edu_mother_4)]<-0

dataset_complete_waves1_2$edu_mother_3[dataset_complete_waves1_2$Dem_Highest_qual_mot=="Hochschule"]<-0
dataset_complete_waves1_2$edu_mother_3[dataset_complete_waves1_2$Dem_Highest_qual_mot=="Sekundarstufe II: Allgemeinbildung"]<-0
dataset_complete_waves1_2$edu_mother_3[dataset_complete_waves1_2$Dem_Highest_qual_mot=="H_here Berufsbildung"]<-1
dataset_complete_waves1_2$edu_mother_3[dataset_complete_waves1_2$Dem_Highest_qual_mot=="Sekundarstufe II: Berufsbildung"]<-0
dataset_complete_waves1_2$edu_mother_3[dataset_complete_waves1_2$Dem_Highest_qual_mot=="Keine nach-obligatorische Ausbildung"]<-0
dataset_complete_waves1_2$edu_mother_3[is.na(dataset_complete_waves1_2$edu_mother_3)]<-0

dataset_complete_waves1_2$edu_mother_2[dataset_complete_waves1_2$Dem_Highest_qual_mot=="Hochschule"]<-0
dataset_complete_waves1_2$edu_mother_2[dataset_complete_waves1_2$Dem_Highest_qual_mot=="Sekundarstufe II: Allgemeinbildung"]<-0
dataset_complete_waves1_2$edu_mother_2[dataset_complete_waves1_2$Dem_Highest_qual_mot=="H_here Berufsbildung"]<-0
dataset_complete_waves1_2$edu_mother_2[dataset_complete_waves1_2$Dem_Highest_qual_mot=="Sekundarstufe II: Berufsbildung"]<-1
dataset_complete_waves1_2$edu_mother_2[dataset_complete_waves1_2$Dem_Highest_qual_mot=="Keine nach-obligatorische Ausbildung"]<-0
dataset_complete_waves1_2$edu_mother_2[is.na(dataset_complete_waves1_2$edu_mother_2)]<-0

dataset_complete_waves1_2$edu_mother_1[dataset_complete_waves1_2$Dem_Highest_qual_mot=="Hochschule"]<-0
dataset_complete_waves1_2$edu_mother_1[dataset_complete_waves1_2$Dem_Highest_qual_mot=="Sekundarstufe II: Allgemeinbildung"]<-0
dataset_complete_waves1_2$edu_mother_1[dataset_complete_waves1_2$Dem_Highest_qual_mot=="H_here Berufsbildung"]<-0
dataset_complete_waves1_2$edu_mother_1[dataset_complete_waves1_2$Dem_Highest_qual_mot=="Sekundarstufe II: Berufsbildung"]<-0
dataset_complete_waves1_2$edu_mother_1[dataset_complete_waves1_2$Dem_Highest_qual_mot=="Keine nach-obligatorische Ausbildung"]<-1
dataset_complete_waves1_2$edu_mother_1[is.na(dataset_complete_waves1_2$edu_mother_1)]<-0

dataset_complete_waves1_2$edu_mother_mis[dataset_complete_waves1_2$Dem_Highest_qual_mot=="Hochschule"]<-0
dataset_complete_waves1_2$edu_mother_mis[dataset_complete_waves1_2$Dem_Highest_qual_mot=="Sekundarstufe II: Allgemeinbildung"]<-0
dataset_complete_waves1_2$edu_mother_mis[dataset_complete_waves1_2$Dem_Highest_qual_mot=="H_here Berufsbildung"]<-0
dataset_complete_waves1_2$edu_mother_mis[dataset_complete_waves1_2$Dem_Highest_qual_mot=="Sekundarstufe II: Berufsbildung"]<-0
dataset_complete_waves1_2$edu_mother_mis[dataset_complete_waves1_2$Dem_Highest_qual_mot=="Keine nach-obligatorische Ausbildung"]<-0
dataset_complete_waves1_2$edu_mother_mis[is.na(dataset_complete_waves1_2$edu_mother_mis)]<-1


#Unniversity division

dataset_complete_waves1_2$division_1[dataset_complete_waves1_2$Dem_Division=="Mathematisch-naturwissenschaftliche Fakult_t"]<-1
dataset_complete_waves1_2$division_1[dataset_complete_waves1_2$Dem_Division=="Medizinische Fakult_t"]<-0
dataset_complete_waves1_2$division_1[dataset_complete_waves1_2$Dem_Division=="Philosophische Fakult_t"]<-0
dataset_complete_waves1_2$division_1[dataset_complete_waves1_2$Dem_Division=="Rechtswissenschaftliche Fakult_t"]<-0
dataset_complete_waves1_2$division_1[dataset_complete_waves1_2$Dem_Division=="Theologische Fakult_t"]<-0
dataset_complete_waves1_2$division_1[dataset_complete_waves1_2$Dem_Division=="Vetsuisse-Fakult_t"]<-0
dataset_complete_waves1_2$division_1[dataset_complete_waves1_2$Dem_Division=="Wirtschaftswissenschaftliche Fakult_t"]<-0
dataset_complete_waves1_2$division_1[is.na(dataset_complete_waves1_2$division_1)]<-0

dataset_complete_waves1_2$division_2[dataset_complete_waves1_2$Dem_Division=="Mathematisch-naturwissenschaftliche Fakult_t"]<-0
dataset_complete_waves1_2$division_2[dataset_complete_waves1_2$Dem_Division=="Medizinische Fakult_t"]<-1
dataset_complete_waves1_2$division_2[dataset_complete_waves1_2$Dem_Division=="Philosophische Fakult_t"]<-0
dataset_complete_waves1_2$division_2[dataset_complete_waves1_2$Dem_Division=="Rechtswissenschaftliche Fakult_t"]<-0
dataset_complete_waves1_2$division_2[dataset_complete_waves1_2$Dem_Division=="Theologische Fakult_t"]<-0
dataset_complete_waves1_2$division_2[dataset_complete_waves1_2$Dem_Division=="Vetsuisse-Fakult_t"]<-0
dataset_complete_waves1_2$division_2[dataset_complete_waves1_2$Dem_Division=="Wirtschaftswissenschaftliche Fakult_t"]<-0
dataset_complete_waves1_2$division_2[is.na(dataset_complete_waves1_2$division_2)]<-0

dataset_complete_waves1_2$division_3[dataset_complete_waves1_2$Dem_Division=="Mathematisch-naturwissenschaftliche Fakult_t"]<-0
dataset_complete_waves1_2$division_3[dataset_complete_waves1_2$Dem_Division=="Medizinische Fakult_t"]<-0
dataset_complete_waves1_2$division_3[dataset_complete_waves1_2$Dem_Division=="Philosophische Fakult_t"]<-1
dataset_complete_waves1_2$division_3[dataset_complete_waves1_2$Dem_Division=="Rechtswissenschaftliche Fakult_t"]<-0
dataset_complete_waves1_2$division_3[dataset_complete_waves1_2$Dem_Division=="Theologische Fakult_t"]<-0
dataset_complete_waves1_2$division_3[dataset_complete_waves1_2$Dem_Division=="Vetsuisse-Fakult_t"]<-0
dataset_complete_waves1_2$division_3[dataset_complete_waves1_2$Dem_Division=="Wirtschaftswissenschaftliche Fakult_t"]<-0
dataset_complete_waves1_2$division_3[is.na(dataset_complete_waves1_2$division_3)]<-0

dataset_complete_waves1_2$division_4[dataset_complete_waves1_2$Dem_Division=="Mathematisch-naturwissenschaftliche Fakult_t"]<-0
dataset_complete_waves1_2$division_4[dataset_complete_waves1_2$Dem_Division=="Medizinische Fakult_t"]<-0
dataset_complete_waves1_2$division_4[dataset_complete_waves1_2$Dem_Division=="Philosophische Fakult_t"]<-0
dataset_complete_waves1_2$division_4[dataset_complete_waves1_2$Dem_Division=="Rechtswissenschaftliche Fakult_t"]<-1
dataset_complete_waves1_2$division_4[dataset_complete_waves1_2$Dem_Division=="Theologische Fakult_t"]<-0
dataset_complete_waves1_2$division_4[dataset_complete_waves1_2$Dem_Division=="Vetsuisse-Fakult_t"]<-0
dataset_complete_waves1_2$division_4[dataset_complete_waves1_2$Dem_Division=="Wirtschaftswissenschaftliche Fakult_t"]<-0
dataset_complete_waves1_2$division_4[is.na(dataset_complete_waves1_2$division_4)]<-0

dataset_complete_waves1_2$division_5[dataset_complete_waves1_2$Dem_Division=="Mathematisch-naturwissenschaftliche Fakult_t"]<-0
dataset_complete_waves1_2$division_5[dataset_complete_waves1_2$Dem_Division=="Medizinische Fakult_t"]<-0
dataset_complete_waves1_2$division_5[dataset_complete_waves1_2$Dem_Division=="Philosophische Fakult_t"]<-0
dataset_complete_waves1_2$division_5[dataset_complete_waves1_2$Dem_Division=="Rechtswissenschaftliche Fakult_t"]<-0
dataset_complete_waves1_2$division_5[dataset_complete_waves1_2$Dem_Division=="Theologische Fakult_t"]<-1
dataset_complete_waves1_2$division_5[dataset_complete_waves1_2$Dem_Division=="Vetsuisse-Fakult_t"]<-0
dataset_complete_waves1_2$division_5[dataset_complete_waves1_2$Dem_Division=="Wirtschaftswissenschaftliche Fakult_t"]<-0
dataset_complete_waves1_2$division_5[is.na(dataset_complete_waves1_2$division_5)]<-0

dataset_complete_waves1_2$division_6[dataset_complete_waves1_2$Dem_Division=="Mathematisch-naturwissenschaftliche Fakult_t"]<-0
dataset_complete_waves1_2$division_6[dataset_complete_waves1_2$Dem_Division=="Medizinische Fakult_t"]<-0
dataset_complete_waves1_2$division_6[dataset_complete_waves1_2$Dem_Division=="Philosophische Fakult_t"]<-0
dataset_complete_waves1_2$division_6[dataset_complete_waves1_2$Dem_Division=="Rechtswissenschaftliche Fakult_t"]<-0
dataset_complete_waves1_2$division_6[dataset_complete_waves1_2$Dem_Division=="Theologische Fakult_t"]<-0
dataset_complete_waves1_2$division_6[dataset_complete_waves1_2$Dem_Division=="Vetsuisse-Fakult_t"]<-1
dataset_complete_waves1_2$division_6[dataset_complete_waves1_2$Dem_Division=="Wirtschaftswissenschaftliche Fakult_t"]<-0
dataset_complete_waves1_2$division_6[is.na(dataset_complete_waves1_2$division_6)]<-0

dataset_complete_waves1_2$division_7[dataset_complete_waves1_2$Dem_Division=="Mathematisch-naturwissenschaftliche Fakult_t"]<-0
dataset_complete_waves1_2$division_7[dataset_complete_waves1_2$Dem_Division=="Medizinische Fakult_t"]<-0
dataset_complete_waves1_2$division_7[dataset_complete_waves1_2$Dem_Division=="Philosophische Fakult_t"]<-0
dataset_complete_waves1_2$division_7[dataset_complete_waves1_2$Dem_Division=="Rechtswissenschaftliche Fakult_t"]<-0
dataset_complete_waves1_2$division_7[dataset_complete_waves1_2$Dem_Division=="Theologische Fakult_t"]<-0
dataset_complete_waves1_2$division_7[dataset_complete_waves1_2$Dem_Division=="Vetsuisse-Fakult_t"]<-0
dataset_complete_waves1_2$division_7[dataset_complete_waves1_2$Dem_Division=="Wirtschaftswissenschaftliche Fakult_t"]<-1
dataset_complete_waves1_2$division_7[is.na(dataset_complete_waves1_2$division_7)]<-0

dataset_complete_waves1_2$division_8[dataset_complete_waves1_2$Dem_Division=="Mathematisch-naturwissenschaftliche Fakult_t"]<-0
dataset_complete_waves1_2$division_8[dataset_complete_waves1_2$Dem_Division=="Medizinische Fakult_t"]<-0
dataset_complete_waves1_2$division_8[dataset_complete_waves1_2$Dem_Division=="Philosophische Fakult_t"]<-0
dataset_complete_waves1_2$division_8[dataset_complete_waves1_2$Dem_Division=="Rechtswissenschaftliche Fakult_t"]<-0
dataset_complete_waves1_2$division_8[dataset_complete_waves1_2$Dem_Division=="Theologische Fakult_t"]<-0
dataset_complete_waves1_2$division_8[dataset_complete_waves1_2$Dem_Division=="Vetsuisse-Fakult_t"]<-0
dataset_complete_waves1_2$division_8[dataset_complete_waves1_2$Dem_Division=="Wirtschaftswissenschaftliche Fakult_t"]<-0
dataset_complete_waves1_2$division_8[is.na(dataset_complete_waves1_2$division_8)]<-1


#Degree type

dataset_complete_waves1_2$degree_1[dataset_complete_waves1_2$Dem_Degree=="Bachelor"]<-1

dataset_complete_waves1_2$degree_1[dataset_complete_waves1_2$Dem_Degree=="Master"]<-0

dataset_complete_waves1_2$degree_1[dataset_complete_waves1_2$Dem_Degree=="Doktorat"]<-0

dataset_complete_waves1_2$degree_1[dataset_complete_waves1_2$Dem_Degree=="Andere (Medizin)"]<-0

dataset_complete_waves1_2$degree_1[dataset_complete_waves1_2$Dem_Degree==""]<-0

dataset_complete_waves1_2$degree_1[is.na(dataset_complete_waves1_2$Dem_Degree)]<-0


dataset_complete_waves1_2$degree_2[dataset_complete_waves1_2$Dem_Degree=="Bachelor"]<-0

dataset_complete_waves1_2$degree_2[dataset_complete_waves1_2$Dem_Degree=="Master"]<-1

dataset_complete_waves1_2$degree_2[dataset_complete_waves1_2$Dem_Degree=="Doktorat"]<-0

dataset_complete_waves1_2$degree_2[dataset_complete_waves1_2$Dem_Degree=="Andere (Medizin)"]<-0

dataset_complete_waves1_2$degree_2[dataset_complete_waves1_2$Dem_Degree==""]<-0

dataset_complete_waves1_2$degree_2[is.na(dataset_complete_waves1_2$Dem_Degree)]<-0


dataset_complete_waves1_2$degree_3[dataset_complete_waves1_2$Dem_Degree=="Bachelor"]<-0

dataset_complete_waves1_2$degree_3[dataset_complete_waves1_2$Dem_Degree=="Master"]<-0

dataset_complete_waves1_2$degree_3[dataset_complete_waves1_2$Dem_Degree=="Doktorat"]<-1

dataset_complete_waves1_2$degree_3[dataset_complete_waves1_2$Dem_Degree=="Andere (Medizin)"]<-0

dataset_complete_waves1_2$degree_3[dataset_complete_waves1_2$Dem_Degree==""]<-0

dataset_complete_waves1_2$degree_3[is.na(dataset_complete_waves1_2$Dem_Degree)]<-0


dataset_complete_waves1_2$degree_4[dataset_complete_waves1_2$Dem_Degree=="Bachelor"]<-0

dataset_complete_waves1_2$degree_4[dataset_complete_waves1_2$Dem_Degree=="Master"]<-0

dataset_complete_waves1_2$degree_4[dataset_complete_waves1_2$Dem_Degree=="Doktorat"]<-0

dataset_complete_waves1_2$degree_4[dataset_complete_waves1_2$Dem_Degree=="Andere (Medizin)"]<-1

dataset_complete_waves1_2$degree_4[dataset_complete_waves1_2$Dem_Degree==""]<-0

dataset_complete_waves1_2$degree_4[is.na(dataset_complete_waves1_2$Dem_Degree)]<-0


dataset_complete_waves1_2$degree_mis[dataset_complete_waves1_2$Dem_Degree=="Bachelor"]<-0

dataset_complete_waves1_2$degree_mis[dataset_complete_waves1_2$Dem_Degree=="Master"]<-0

dataset_complete_waves1_2$degree_mis[dataset_complete_waves1_2$Dem_Degree=="Doktorat"]<-0

dataset_complete_waves1_2$degree_mis[dataset_complete_waves1_2$Dem_Degree=="Andere (Medizin)"]<-0

dataset_complete_waves1_2$degree_mis[dataset_complete_waves1_2$Dem_Degree==""]<-1

dataset_complete_waves1_2$degree_mis[is.na(dataset_complete_waves1_2$Dem_Degree)]<-1


#Wave 1 attitudes (baseline)


#Future Optimistic

dataset_complete_waves1_2$future_per[dataset_complete_waves1_2$W1_Future=="Sehr zuversichtlich"]<-4

dataset_complete_waves1_2$future_per[dataset_complete_waves1_2$W1_Future=="Zuversichtlich"]<-3

dataset_complete_waves1_2$future_per[dataset_complete_waves1_2$W1_Future=="Weder noch"]<-2

dataset_complete_waves1_2$future_per[dataset_complete_waves1_2$W1_Future=="Wenig zuversichtlich"]<-1

dataset_complete_waves1_2$future_per[dataset_complete_waves1_2$W1_Future=="Gar nicht zuversichtlich"]<-0

dataset_complete_waves1_2$future_per[dataset_complete_waves1_2$W1_Future==""]<-NA

table(dataset_complete_waves1_2$future_per)


#Future Per missing dummy

dataset_complete_waves1_2$future_per_mis[is.na(dataset_complete_waves1_2$future_per)]<-1
dataset_complete_waves1_2$future_per_mis[!is.na(dataset_complete_waves1_2$future_per)]<-0


#Impute median for missing

median(dataset_complete_waves1_2$future_per, na.rm=TRUE)

dataset_complete_waves1_2$future_per[is.na(dataset_complete_waves1_2$future_per)]<-median(dataset_complete_waves1_2$future_per, na.rm=TRUE)



#Professional Goals

dataset_complete_waves1_2$career_goals_1[dataset_complete_waves1_2$W1_Professional_Goal=="Ja"]<-1

dataset_complete_waves1_2$career_goals_1[dataset_complete_waves1_2$W1_Professional_Goal=="Nein"]<-0

dataset_complete_waves1_2$career_goals_1[is.na(dataset_complete_waves1_2$career_goals_1)]<-0


dataset_complete_waves1_2$career_goals_2[dataset_complete_waves1_2$W1_Professional_Goal=="Ja"]<-0

dataset_complete_waves1_2$career_goals_2[dataset_complete_waves1_2$W1_Professional_Goal=="Nein"]<-1

dataset_complete_waves1_2$career_goals_2[is.na(dataset_complete_waves1_2$career_goals_2)]<-0


dataset_complete_waves1_2$career_goals_3[dataset_complete_waves1_2$W1_Professional_Goal=="Ja"]<-0

dataset_complete_waves1_2$career_goals_3[dataset_complete_waves1_2$W1_Professional_Goal=="Nein"]<-0

dataset_complete_waves1_2$career_goals_3[is.na(dataset_complete_waves1_2$career_goals_3)]<-1



#Profession Entry

table(dataset_complete_waves1_2$W1_Profession_Entry)

dataset_complete_waves1_2$career_entry_1[dataset_complete_waves1_2$W1_Profession_Entry=="Ja"]<-1

dataset_complete_waves1_2$career_entry_1[dataset_complete_waves1_2$W1_Profession_Entry=="Nein"]<-0

dataset_complete_waves1_2$career_entry_1[is.na(dataset_complete_waves1_2$career_entry_1)]<-0


dataset_complete_waves1_2$career_entry_2[dataset_complete_waves1_2$W1_Profession_Entry=="Ja"]<-0

dataset_complete_waves1_2$career_entry_2[dataset_complete_waves1_2$W1_Profession_Entry=="Nein"]<-1

dataset_complete_waves1_2$career_entry_2[is.na(dataset_complete_waves1_2$career_entry_2)]<-0


dataset_complete_waves1_2$career_entry_3[dataset_complete_waves1_2$W1_Profession_Entry=="Ja"]<-0

dataset_complete_waves1_2$career_entry_3[dataset_complete_waves1_2$W1_Profession_Entry=="Nein"]<-0

dataset_complete_waves1_2$career_entry_3[is.na(dataset_complete_waves1_2$career_entry_3)]<-1



#Children

dataset_complete_waves1_2$children_1[dataset_complete_waves1_2$W1_Children=="Ja"]<-1

dataset_complete_waves1_2$children_1[dataset_complete_waves1_2$W1_Children=="Nein"]<-0

dataset_complete_waves1_2$children_1[dataset_complete_waves1_2$W1_Children=="Vielleicht"]<-0

dataset_complete_waves1_2$children_1[is.na(dataset_complete_waves1_2$children_1)]<-0


dataset_complete_waves1_2$children_2[dataset_complete_waves1_2$W1_Children=="Ja"]<-0

dataset_complete_waves1_2$children_2[dataset_complete_waves1_2$W1_Children=="Nein"]<-1

dataset_complete_waves1_2$children_2[dataset_complete_waves1_2$W1_Children=="Vielleicht"]<-0

dataset_complete_waves1_2$children_2[is.na(dataset_complete_waves1_2$children_2)]<-0


dataset_complete_waves1_2$children_3[dataset_complete_waves1_2$W1_Children=="Ja"]<-0

dataset_complete_waves1_2$children_3[dataset_complete_waves1_2$W1_Children=="Nein"]<-0

dataset_complete_waves1_2$children_3[dataset_complete_waves1_2$W1_Children=="Vielleicht"]<-1

dataset_complete_waves1_2$children_3[is.na(dataset_complete_waves1_2$children_3)]<-0


dataset_complete_waves1_2$children_mis[dataset_complete_waves1_2$W1_Children=="Ja"]<-0

dataset_complete_waves1_2$children_mis[dataset_complete_waves1_2$W1_Children=="Nein"]<-0

dataset_complete_waves1_2$children_mis[dataset_complete_waves1_2$W1_Children=="Vielleicht"]<-0

dataset_complete_waves1_2$children_mis[is.na(dataset_complete_waves1_2$children_mis)]<-1



#Skills

dataset_complete_waves1_2$social_skills[dataset_complete_waves1_2$W1_Skills_Social=="Stimme voll zu"]<-4

dataset_complete_waves1_2$social_skills[dataset_complete_waves1_2$W1_Skills_Social=="Stimme eher zu"]<-3

dataset_complete_waves1_2$social_skills[dataset_complete_waves1_2$W1_Skills_Social=="Weder noch"]<-2

dataset_complete_waves1_2$social_skills[dataset_complete_waves1_2$W1_Skills_Social=="Stimme eher nicht zu"]<-1

dataset_complete_waves1_2$social_skills[dataset_complete_waves1_2$W1_Skills_Social=="Stimme gar nicht zu"]<-0

dataset_complete_waves1_2$social_skills[dataset_complete_waves1_2$W1_Skills_Social==""]<-NA


#Impute median for missing

median(dataset_complete_waves1_2$social_skills, na.rm=TRUE)

dataset_complete_waves1_2$social_skills[is.na(dataset_complete_waves1_2$social_skills)]<-median(dataset_complete_waves1_2$social_skills, na.rm=TRUE)


#missing dummy

dataset_complete_waves1_2$social_skills_mis<-0
dataset_complete_waves1_2$social_skills_mis[dataset_complete_waves1_2$W1_Skills_Social==""]<-1


dataset_complete_waves1_2$presentation_skills[dataset_complete_waves1_2$W1_Skills_Present=="Stimme voll zu"]<-4

dataset_complete_waves1_2$presentation_skills[dataset_complete_waves1_2$W1_Skills_Present=="Stimme eher zu"]<-3

dataset_complete_waves1_2$presentation_skills[dataset_complete_waves1_2$W1_Skills_Present=="Weder noch"]<-2

dataset_complete_waves1_2$presentation_skills[dataset_complete_waves1_2$W1_Skills_Present=="Stimme eher nicht zu"]<-1

dataset_complete_waves1_2$presentation_skills[dataset_complete_waves1_2$W1_Skills_Present=="Stimme gar nicht zu"]<-0

dataset_complete_waves1_2$presentation_skills[dataset_complete_waves1_2$W1_Skills_Present==""]<-NA


#Impute median for missing

median(dataset_complete_waves1_2$presentation_skills, na.rm=TRUE)

dataset_complete_waves1_2$presentation_skills[is.na(dataset_complete_waves1_2$presentation_skills)]<-median(dataset_complete_waves1_2$presentation_skills, na.rm=TRUE)


# missing dummy

dataset_complete_waves1_2$presentation_skills_mis<-0
dataset_complete_waves1_2$presentation_skills_mis[dataset_complete_waves1_2$W1_Skills_Present==""]<-1


#Network Skills

dataset_complete_waves1_2$networking_skills[dataset_complete_waves1_2$W1_Skills_Network=="Stimme voll zu"]<-4

dataset_complete_waves1_2$networking_skills[dataset_complete_waves1_2$W1_Skills_Network=="Stimme eher zu"]<-3

dataset_complete_waves1_2$networking_skills[dataset_complete_waves1_2$W1_Skills_Network=="Weder noch"]<-2

dataset_complete_waves1_2$networking_skills[dataset_complete_waves1_2$W1_Skills_Network=="Stimme eher nicht zu"]<-1

dataset_complete_waves1_2$networking_skills[dataset_complete_waves1_2$W1_Skills_Network=="Stimme gar nicht zu"]<-0

dataset_complete_waves1_2$networking_skills[dataset_complete_waves1_2$W1_Skills_Network==""]<-NA


#Impute median for missing

median(dataset_complete_waves1_2$networking_skills, na.rm=TRUE)

dataset_complete_waves1_2$networking_skills[is.na(dataset_complete_waves1_2$networking_skills)]<-median(dataset_complete_waves1_2$networking_skills, na.rm=TRUE)


#missing dummy

dataset_complete_waves1_2$networking_skills_mis<-0
dataset_complete_waves1_2$networking_skills_mis[dataset_complete_waves1_2$W1_Skills_Network==""]<-1


#Running for office

dataset_complete_waves1_2$running_for_office[dataset_complete_waves1_2$W1_Run_Office=="Stimme voll zu"]<-4

dataset_complete_waves1_2$running_for_office[dataset_complete_waves1_2$W1_Run_Office=="Stimme eher zu"]<-3

dataset_complete_waves1_2$running_for_office[dataset_complete_waves1_2$W1_Run_Office=="Weder noch"]<-2

dataset_complete_waves1_2$running_for_office[dataset_complete_waves1_2$W1_Run_Office=="Stimme eher nicht zu"]<-1

dataset_complete_waves1_2$running_for_office[dataset_complete_waves1_2$W1_Run_Office=="Stimme gar nicht zu"]<-0

dataset_complete_waves1_2$running_for_office[dataset_complete_waves1_2$W1_Run_Office==""]<-NA


#Impute median for missing

median(dataset_complete_waves1_2$running_for_office, na.rm=TRUE)

dataset_complete_waves1_2$running_for_office[is.na(dataset_complete_waves1_2$running_for_office)]<-median(dataset_complete_waves1_2$running_for_office, na.rm=TRUE)


#missing dummy

dataset_complete_waves1_2$running_for_office_mis<-0
dataset_complete_waves1_2$running_for_office_mis[dataset_complete_waves1_2$W1_Run_Office==""]<-1


#Attitude towards politicians

dataset_complete_waves1_2$politicians[dataset_complete_waves1_2$W1_Politicians=="Stimme voll zu"]<-4

dataset_complete_waves1_2$politicians[dataset_complete_waves1_2$W1_Politicians=="Stimme eher zu"]<-3

dataset_complete_waves1_2$politicians[dataset_complete_waves1_2$W1_Politicians=="Weder noch"]<-2

dataset_complete_waves1_2$politicians[dataset_complete_waves1_2$W1_Politicians=="Stimme eher nicht zu"]<-1

dataset_complete_waves1_2$politicians[dataset_complete_waves1_2$W1_Politicians=="Stimme gar nicht zu"]<-0

dataset_complete_waves1_2$politicians[dataset_complete_waves1_2$W1_Politicians==""]<-NA


#Impute median for missing

median(dataset_complete_waves1_2$politicians, na.rm=TRUE)

dataset_complete_waves1_2$politicians[is.na(dataset_complete_waves1_2$politicians)]<-median(dataset_complete_waves1_2$politicians, na.rm=TRUE)


#missing dummy

dataset_complete_waves1_2$politicians_mis<-0
dataset_complete_waves1_2$politicians_mis[dataset_complete_waves1_2$W1_Politicians==""]<-1


#Gender attitudes - childcare

dataset_complete_waves1_2$W1_Gender_Childcare

dataset_complete_waves1_2$gender_childcare[dataset_complete_waves1_2$W1_Gender_Childcare=="Stimme voll zu"]<-4

dataset_complete_waves1_2$gender_childcare[dataset_complete_waves1_2$W1_Gender_Childcare=="Stimme eher zu"]<-3

dataset_complete_waves1_2$gender_childcare[dataset_complete_waves1_2$W1_Gender_Childcare=="Weder noch"]<-2

dataset_complete_waves1_2$gender_childcare[dataset_complete_waves1_2$W1_Gender_Childcare=="Stimme eher nicht zu"]<-1

dataset_complete_waves1_2$gender_childcare[dataset_complete_waves1_2$W1_Gender_Childcare=="Stimme gar nicht zu"]<-0

dataset_complete_waves1_2$gender_childcare[dataset_complete_waves1_2$W1_Gender_Childcare==""]<-NA


#Impute median for missing

median(dataset_complete_waves1_2$gender_childcare, na.rm=TRUE)

dataset_complete_waves1_2$gender_childcare[is.na(dataset_complete_waves1_2$gender_childcare)]<-median(dataset_complete_waves1_2$gender_childcare, na.rm=TRUE)


#missing dummy

dataset_complete_waves1_2$gender_childcare_mis<-0
dataset_complete_waves1_2$gender_childcare_mis[dataset_complete_waves1_2$W1_Gender_Childcare==""]<-1


#Gender attitudes - career

dataset_complete_waves1_2$gender_career[dataset_complete_waves1_2$W1_Gender_Career=="Stimme voll zu"]<-4

dataset_complete_waves1_2$gender_career[dataset_complete_waves1_2$W1_Gender_Career=="Stimme eher zu"]<-3

dataset_complete_waves1_2$gender_career[dataset_complete_waves1_2$W1_Gender_Career=="Weder noch"]<-2

dataset_complete_waves1_2$gender_career[dataset_complete_waves1_2$W1_Gender_Career=="Stimme eher nicht zu"]<-1

dataset_complete_waves1_2$gender_career[dataset_complete_waves1_2$W1_Gender_Career=="Stimme gar nicht zu"]<-0

dataset_complete_waves1_2$gender_career[dataset_complete_waves1_2$W1_Gender_Career==""]<-NA


#Impute median for missing

median(dataset_complete_waves1_2$gender_career, na.rm=TRUE)

dataset_complete_waves1_2$gender_career[is.na(dataset_complete_waves1_2$gender_career)]<-median(dataset_complete_waves1_2$gender_career, na.rm=TRUE)


#missing dummy

dataset_complete_waves1_2$gender_career_mis<-0
dataset_complete_waves1_2$gender_career_mis[dataset_complete_waves1_2$W1_Gender_Career==""]<-1


#Gender attitudes - elections

dataset_complete_waves1_2$gender_election[dataset_complete_waves1_2$W1_Gender_Election=="Stimme voll zu"]<-4

dataset_complete_waves1_2$gender_election[dataset_complete_waves1_2$W1_Gender_Election=="Stimme eher zu"]<-3

dataset_complete_waves1_2$gender_election[dataset_complete_waves1_2$W1_Gender_Election=="Weder noch"]<-2

dataset_complete_waves1_2$gender_election[dataset_complete_waves1_2$W1_Gender_Election=="Stimme eher nicht zu"]<-1

dataset_complete_waves1_2$gender_election[dataset_complete_waves1_2$W1_Gender_Election=="Stimme gar nicht zu"]<-0

dataset_complete_waves1_2$gender_election[dataset_complete_waves1_2$W1_Gender_Election==""]<-NA


#Impute median for missing

median(dataset_complete_waves1_2$gender_election, na.rm=TRUE)

dataset_complete_waves1_2$gender_election[is.na(dataset_complete_waves1_2$gender_election)]<-median(dataset_complete_waves1_2$gender_election, na.rm=TRUE)


#missing dummy

dataset_complete_waves1_2$gender_election_mis<-0
dataset_complete_waves1_2$gender_election_mis[dataset_complete_waves1_2$W1_Gender_Election==""]<-1


#Gender attitudes - work

dataset_complete_waves1_2$gender_work[dataset_complete_waves1_2$W1_Gender_Work=="Stimme voll zu"]<-0

dataset_complete_waves1_2$gender_work[dataset_complete_waves1_2$W1_Gender_Work=="Stimme eher zu"]<-1

dataset_complete_waves1_2$gender_work[dataset_complete_waves1_2$W1_Gender_Work=="Weder noch"]<-2

dataset_complete_waves1_2$gender_work[dataset_complete_waves1_2$W1_Gender_Work=="Stimme eher nicht zu"]<-3

dataset_complete_waves1_2$gender_work[dataset_complete_waves1_2$W1_Gender_Work=="Stimme gar nicht zu"]<-4

dataset_complete_waves1_2$gender_work[dataset_complete_waves1_2$W1_Gender_Work==""]<-NA


#Impute median for missing

median(dataset_complete_waves1_2$gender_work, na.rm=TRUE)

dataset_complete_waves1_2$gender_work[is.na(dataset_complete_waves1_2$gender_work)]<-median(dataset_complete_waves1_2$gender_work, na.rm=TRUE)


#missing dummy

dataset_complete_waves1_2$gender_work_mis<-0
dataset_complete_waves1_2$gender_work_mis[dataset_complete_waves1_2$W1_Gender_Work==""]<-1


#Gender attitudes - politics

dataset_complete_waves1_2$gender_politics[dataset_complete_waves1_2$W1_Gender_Politics=="Stimme voll zu"]<-4

dataset_complete_waves1_2$gender_politics[dataset_complete_waves1_2$W1_Gender_Politics=="Stimme eher zu"]<-3

dataset_complete_waves1_2$gender_politics[dataset_complete_waves1_2$W1_Gender_Politics=="Weder noch"]<-2

dataset_complete_waves1_2$gender_politics[dataset_complete_waves1_2$W1_Gender_Politics=="Stimme eher nicht zu"]<-1

dataset_complete_waves1_2$gender_politics[dataset_complete_waves1_2$W1_Gender_Politics=="Stimme gar nicht zu"]<-0

dataset_complete_waves1_2$gender_politics[dataset_complete_waves1_2$W1_Gender_Politics==""]<-NA


#Impute median for missing

median(dataset_complete_waves1_2$gender_politics, na.rm=TRUE)

dataset_complete_waves1_2$gender_politics[is.na(dataset_complete_waves1_2$gender_politics)]<-median(dataset_complete_waves1_2$gender_politics, na.rm=TRUE)


#missing dummy

dataset_complete_waves1_2$gender_politics_mis<-0
dataset_complete_waves1_2$gender_politics_mis[dataset_complete_waves1_2$W1_Gender_Politics==""]<-1



#Gender attitudes - children

dataset_complete_waves1_2$gender_children[dataset_complete_waves1_2$W1_Gender_Children=="Stimme voll zu"]<-4

dataset_complete_waves1_2$gender_children[dataset_complete_waves1_2$W1_Gender_Children=="Stimme eher zu"]<-3

dataset_complete_waves1_2$gender_children[dataset_complete_waves1_2$W1_Gender_Children=="Weder noch"]<-2

dataset_complete_waves1_2$gender_children[dataset_complete_waves1_2$W1_Gender_Children=="Stimme eher nicht zu"]<-1

dataset_complete_waves1_2$gender_children[dataset_complete_waves1_2$W1_Gender_Children=="Stimme gar nicht zu"]<-0

dataset_complete_waves1_2$gender_children[dataset_complete_waves1_2$W1_Gender_Children==""]<-NA


#Impute median for missing

median(dataset_complete_waves1_2$gender_children, na.rm=TRUE)

dataset_complete_waves1_2$gender_children[is.na(dataset_complete_waves1_2$gender_children)]<-median(dataset_complete_waves1_2$gender_children, na.rm=TRUE)


#missing dummy

dataset_complete_waves1_2$gender_children_mis<-0
dataset_complete_waves1_2$gender_children_mis[dataset_complete_waves1_2$W1_Gender_Children==""]<-1


#Economic Interest
dataset_complete_waves1_2$econ_interest<-dataset_complete_waves1_2$W1_Econ_Interst_1

median(dataset_complete_waves1_2$econ_interest, na.rm=TRUE)

dataset_complete_waves1_2$econ_interest[is.na(dataset_complete_waves1_2$econ_interest)]<-median(dataset_complete_waves1_2$econ_interest, na.rm=TRUE)


#Political Interest

dataset_complete_waves1_2$pol_interest<-dataset_complete_waves1_2$W1_Pol_Interest_1

median(dataset_complete_waves1_2$pol_interest, na.rm=TRUE)

dataset_complete_waves1_2$pol_interest[is.na(dataset_complete_waves1_2$pol_interest)]<-median(dataset_complete_waves1_2$pol_interest, na.rm=TRUE)


#Political Knowledge Self-Report

dataset_complete_waves1_2$pol_knowledge_self_report<-dataset_complete_waves1_2$W1_Pol_Know_1

median(dataset_complete_waves1_2$pol_knowledge_self_report, na.rm=TRUE)

dataset_complete_waves1_2$pol_knowledge_self_report[is.na(dataset_complete_waves1_2$pol_knowledge_self_report)]<-median(dataset_complete_waves1_2$pol_knowledge_self_report, na.rm=TRUE)


#missing dummies

dataset_complete_waves1_2$econ_interest_mis[is.na(dataset_complete_waves1_2$W1_Econ_Interst_1)]<-1
dataset_complete_waves1_2$econ_interest_mis[!is.na(dataset_complete_waves1_2$W1_Econ_Interst_1)]<-0

dataset_complete_waves1_2$pol_interest_mis[is.na(dataset_complete_waves1_2$W1_Pol_Interest_1)]<-1
dataset_complete_waves1_2$pol_interest_mis[!is.na(dataset_complete_waves1_2$W1_Pol_Interest_1)]<-0

dataset_complete_waves1_2$pol_knowledge_self_report_mis[is.na(dataset_complete_waves1_2$W1_Pol_Know_1)]<-1
dataset_complete_waves1_2$pol_knowledge_self_report_mis[!is.na(dataset_complete_waves1_2$W1_Pol_Know_1)]<-0


#Political knowledge

dataset_complete_waves1_2$W1_knowledge_male<-dataset_complete_waves1_2$W1_Know_Male_Proportion

mean(dataset_complete_waves1_2$W1_knowledge_male, na.rm=TRUE)

dataset_complete_waves1_2$W1_knowledge_male[is.na(dataset_complete_waves1_2$W1_knowledge_male)]<-mean(dataset_complete_waves1_2$W1_knowledge_male, na.rm=TRUE)

dataset_complete_waves1_2$knowledge_male_mis[is.na(dataset_complete_waves1_2$W1_Know_Male_Proportion)]<-1
dataset_complete_waves1_2$knowledge_male_mis[!is.na(dataset_complete_waves1_2$W1_Know_Male_Proportion)]<-0

dataset_complete_waves1_2$W1_knowledge_female<-dataset_complete_waves1_2$W1_Know_Female_Proportion

mean(dataset_complete_waves1_2$W1_knowledge_female, na.rm=TRUE)

dataset_complete_waves1_2$W1_knowledge_female[is.na(dataset_complete_waves1_2$W1_knowledge_female)]<-mean(dataset_complete_waves1_2$W1_knowledge_female, na.rm=TRUE)

dataset_complete_waves1_2$knowledge_female_mis[is.na(dataset_complete_waves1_2$W1_Know_Female_Proportion)]<-1
dataset_complete_waves1_2$knowledge_female_mis[!is.na(dataset_complete_waves1_2$W1_Know_Female_Proportion)]<-0


#Outcome Variables Wave 2 (endline)

#Running for office

dataset_complete_waves1_2$running_for_office_w2[dataset_complete_waves1_2$W2_Run_Office=="Stimme voll zu"]<-4

dataset_complete_waves1_2$running_for_office_w2[dataset_complete_waves1_2$W2_Run_Office=="Stimme eher zu"]<-3

dataset_complete_waves1_2$running_for_office_w2[dataset_complete_waves1_2$W2_Run_Office=="Weder noch"]<-2

dataset_complete_waves1_2$running_for_office_w2[dataset_complete_waves1_2$W2_Run_Office=="Stimme eher nicht zu"]<-1

dataset_complete_waves1_2$running_for_office_w2[dataset_complete_waves1_2$W2_Run_Office=="Stimme gar nicht zu"]<-0

#Follow campaignn

dataset_complete_waves1_2$campaign_media_w2<-dataset_complete_waves1_2$W2_Campaign_Media_1


#Follow campaign online

dataset_complete_waves1_2$campaign_online_w2<-NA
dataset_complete_waves1_2$campaign_online_w2[dataset_complete_waves1_2$W2_Campaign_Online=="T_glich"]<-4
dataset_complete_waves1_2$campaign_online_w2[dataset_complete_waves1_2$W2_Campaign_Online=="Mehrmals w_chentlich"]<- 3
dataset_complete_waves1_2$campaign_online_w2[dataset_complete_waves1_2$W2_Campaign_Online=="Ein Mal w_chentlich"]<-2
dataset_complete_waves1_2$campaign_online_w2[dataset_complete_waves1_2$W2_Campaign_Online=="Ein paar Mal pro Monat"]<-1
dataset_complete_waves1_2$campaign_online_w2[dataset_complete_waves1_2$W2_Campaign_Online=="Nie"]<-0

#Political Knowledge

dataset_complete_waves1_2$W2_knowledge<-dataset_complete_waves1_2$W2_Knowledge


#Rename variables

dataset_complete_waves1_2$Treatment<-NA
dataset_complete_waves1_2$Treatment<-dataset_complete_waves1_2$treatment

dataset_complete_waves1_2$Comply<-NA
dataset_complete_waves1_2$Comply<-dataset_complete_waves1_2$comply

dataset_complete_waves1_2$Attendance<-NA
dataset_complete_waves1_2$Attendance<-dataset_complete_waves1_2$attend

dataset_complete_waves1_2$Application<-NA
dataset_complete_waves1_2$Application<-dataset_complete_waves1_2$apply

dataset_complete_waves1_2$Answer_invite<-NA
dataset_complete_waves1_2$Answer_invite<-dataset_complete_waves1_2$answer

dataset_complete_waves1_2$Block<-NA
dataset_complete_waves1_2$Block<-dataset_complete_waves1_2$block


#Female variable

dataset_complete_waves1_2$female_gen[dataset_complete_waves1_2$Dem_Gender=="M_nnlich"]<-0
dataset_complete_waves1_2$female_gen[dataset_complete_waves1_2$Dem_Gender=="Weiblich"]<-1
dataset_complete_waves1_2$female_gen[is.na(dataset_complete_waves1_2$Dem_Gender)]<-0
dataset_complete_waves1_2$female_gen[dataset_complete_waves1_2$Dem_Gender==""]<-0

dataset_complete_waves1_2$female_mis<-0
dataset_complete_waves1_2$female_mis[dataset_complete_waves1_2$Dem_Gender==""]<-1
dataset_complete_waves1_2$female_gen[is.na(dataset_complete_waves1_2$Dem_Gender)]<-0

#Female vs male binary

dataset_complete_waves1_2$fem<-NA
dataset_complete_waves1_2$fem[dataset_complete_waves1_2$female_gen==1]<-1
dataset_complete_waves1_2$fem[dataset_complete_waves1_2$female_gen==0 & dataset_complete_waves1_2$female_mis==0]<-0

dataset_complete_analysis<-dataset_complete_waves1_2[,41:135]

names(dataset_complete_analysis)


#Save dataframe for analysis

saveRDS(dataset_complete_analysis, file="dataset_complete_analysis.rds")